package com.apps.ftapp.db;

import com.apps.ftapp.util.Tools;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by lyli on 2017/10/24.
 */

public class Singleton {

    /* 持有私有静态实例，防止被引用，此处赋值为null，目的是实现延迟加载 */
    private static Singleton instance = null;

    private List<Map> datas = new ArrayList<>();

    private List<Map> datiList = new ArrayList<>();

    private String startTime;

    private String endTime;

    private String id;


    /* 私有构造方法，防止被实例化 */
    private Singleton() {
    }

    /* 1:懒汉式，静态工程方法，创建实例 */
    public static Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }


    public List<Map> getDatiList() {
        return datiList;
    }

    public void setDatiList(List<Map> datiList) {
        this.datiList = datiList;
    }

    public void updDatiList(int index, boolean flag) {
        for (Map tmp : this.datiList) {
            if (Tools.isIntNull(tmp.get("index")) == index) {
                tmp.put("is", flag);
            }
        }
    }


    public void clearDati() {
        this.datiList.clear();
    }


    public void addD(Map map) {
        this.datiList.add(map);
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public List<Map> getDatas() {
        return datas;
    }

    public void setDatas(List<Map> datas) {
        this.datas = datas;
    }


    public void addData(Map map) {
        this.datas.add(map);
    }


    public void clear() {
        this.datas.clear();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

}
